package blog.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import blog.entity.Article;
import blog.entity.Comment;
import blog.mapper.ArticleMapper;
import blog.mapper.CommentMapper;
import blog.service.CommentService;
@Service
public class CommentServiceImpl implements CommentService{
    @Resource
    private CommentMapper commentMapper;
    @Resource
    private ArticleMapper articleMapper;
 @Override
 public List<Comment> listRecentComment(Integer n) {
  List <Comment> commentList=commentMapper.listRecentComment(n);
  for(Comment c:commentList) { 
   Article article =articleMapper.getArticleById(c.getCommentArticleId());
   c.setArticle(article);
  }
  return  commentList; 
 }

}